/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "document_category")
@NamedQueries({
    @NamedQuery(name = "DocumentCategory.findAll", query = "SELECT d FROM DocumentCategory d"),
    @NamedQuery(name = "DocumentCategory.findByDcId", query = "SELECT d FROM DocumentCategory d WHERE d.dcId = :dcId"),
    @NamedQuery(name = "DocumentCategory.findByDcName", query = "SELECT d FROM DocumentCategory d WHERE d.dcName = :dcName"),
    @NamedQuery(name = "DocumentCategory.findByDcDescrip", query = "SELECT d FROM DocumentCategory d WHERE d.dcDescrip = :dcDescrip")})
public class DocumentCategory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "dc_id")
    private Integer dcId;
    @Basic(optional = false)
    @Column(name = "dc_name")
    private String dcName;
    @Column(name = "dc_descrip")
    private String dcDescrip;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "documentCategory", fetch = FetchType.LAZY)
    private List<DocumentCategory> documentCategoryList;
    @JoinColumn(name = "dc_former", referencedColumnName = "dc_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private DocumentCategory documentCategory;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "documentCategory", fetch = FetchType.LAZY)
    private List<Document> documentList;

    public DocumentCategory() {
    }

    public DocumentCategory(Integer dcId) {
        this.dcId = dcId;
    }

    public DocumentCategory(Integer dcId, String dcName) {
        this.dcId = dcId;
        this.dcName = dcName;
    }

    public Integer getDcId() {
        return dcId;
    }

    public void setDcId(Integer dcId) {
        this.dcId = dcId;
    }

    public String getDcName() {
        return dcName;
    }

    public void setDcName(String dcName) {
        this.dcName = dcName;
    }

    public String getDcDescrip() {
        return dcDescrip;
    }

    public void setDcDescrip(String dcDescrip) {
        this.dcDescrip = dcDescrip;
    }

    public List<DocumentCategory> getDocumentCategoryList() {
        return documentCategoryList;
    }

    public void setDocumentCategoryList(List<DocumentCategory> documentCategoryList) {
        this.documentCategoryList = documentCategoryList;
    }

    public DocumentCategory getDocumentCategory() {
        return documentCategory;
    }

    public void setDocumentCategory(DocumentCategory documentCategory) {
        this.documentCategory = documentCategory;
    }

    public List<Document> getDocumentList() {
        return documentList;
    }

    public void setDocumentList(List<Document> documentList) {
        this.documentList = documentList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dcId != null ? dcId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DocumentCategory)) {
            return false;
        }
        DocumentCategory other = (DocumentCategory) object;
        if ((this.dcId == null && other.dcId != null) || (this.dcId != null && !this.dcId.equals(other.dcId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.DocumentCategory[dcId=" + dcId + "]";
    }

}
